/*
 * MapElementFactory.cpp
 *
 *  Created on: 31/10/2009
 *      Author: marcos
 */

#include "MapElementFactory.h"

MapElementFactory::MapElementFactory() { }

MapElementFactory::~MapElementFactory() { }

void MapElementFactory::createRoad(Map* map, parser::ParsedData* data)
	throw (DuplicateElementException, ElementNotFoundException){
	parser::RoadParsedData* road = (parser::RoadParsedData*)data;
	map->addRoad(road->getId(), road->getRoadName(), road->getIdO(), road->getIdD(),
		road->getLength(), road->getMaxSpeed(), road->getRoadType(), road->getInitialNumber(), road->getFinalNumber());
}

void MapElementFactory::createLocation(Map* map, parser::ParsedData* data)
	throw (DuplicateElementException){
	parser::MapLocationParsedData* location = (parser::MapLocationParsedData*)data;
	map->addLocation(location->getId(), location->getRoadId(), location->getNumber(), location->getType());
}

void MapElementFactory::createIntersection(Map* map, parser::ParsedData* data)
	throw (DuplicateElementException, ElementNotFoundException){
	parser::IntersectionParsedData* inter = (parser::IntersectionParsedData*)data;
	map->addIntersection(inter->getId(), inter->getX(), inter->getY());
}
